<template>
	<view class="shangc-box">
		<view class="shangc-neir" v-for="(item,index) in arrcont" :key="index">
			<label :for="item.id">
				{{item.name}}
			</label>
			<input type="text" :id="item.id" :type="item.type" :placeholder="'请输入'  + item.name" v-model="item.text"
				name="">
			<view class="" style="padding: 20rpx;"  v-show="item.fuz" @click="fuz(item)">
				查询
			</view>
			<view class="" v-show="geshu">
				{{item.hou}}
			</view>
		</view>


		<view class="shangc-neir">
			<view>
				数量
			</view>
			<input type="text" v-model="geshu">
		</view>

		<view class="unpdata" @click="UploadProducts">
			修改仓库
		</view>
	</view>
</template>

<script>
	import api from '../../api/Channel.js'
	import commonMixin from '@/mixins/qiLiuyun.js';
	import request from '../../api/index.js'
	import suffixAddress from '../../api/suffixAddress.js'
	export default {
		mixins: [commonMixin],
		data() {
			return {
				geshu: '暂无',
				arrcont: [{
						name: '名称',
						text: '',
						type: 'text',
						hou: '',
						id: 0,
						fuz: true

					},
					{
						name: '修改',
						text: '',
						type: 'text',
						hou: '',
						id: 0,
						fuz: false

					},
				],

			};
		},
		onLoad() {

		},
		methods: {



			async UploadProducts() {
				if(this.geshu == '暂无'){
					
					uni.showToast({
						title: '请点击查询',
						icon: 'error', // 可选值：success、loa ding、none
						duration: 1000, // 显示时长（单位：ms）
					
					});
					return
				}
				if(this.geshu  == 0){
					uni.showToast({
						title: '没有该产品',
						icon: 'error', // 可选值：success、loa ding、none
						duration: 1000, // 显示时长（单位：ms）
					
					});
					
					return
				}
				
				
		
				let th = this
				let obj = {
					data: {
						"oldSourceIndex": this.arrcont[0].text,
						"newSourceIndex":this.arrcont[1].text
					},
					url: api.ctrl + '/commodities/warehouse/batch',
					method: "PUT",
				}

				let res = await request(obj)
				console.log(res)
				uni.hideLoading()
				uni.showToast({
					title: '修改成功',
					icon: 'success', // 可选值：success、loa ding、none
					duration: 1000, // 显示时长（单位：ms）

				});
			},

			async fuz(item) {
				if (item.text == '') {
					uni.showToast({
						title: '不能为空',
						icon: 'error', // 可选值：success、loading、none
						duration: 1000, // 显示时长（单位：ms）

					});
					return
				}
				let obj = {
					data: {
						prefix: item.text
					},
					url: api.ctrl + '/commodities/count/prefix',
					method: "GET",
				}
				let res = await request(obj)
				uni.showToast({
					title: '查询成功',
					icon: 'success', // 可选值：success、loa ding、none
					duration: 1000, // 显示时长（单位：ms）
				
				});
				this.geshu = res.data
			}
		}
	}
</script>

<style lang="less">
	.shangc-box {
		background-color: #F5F5F5;
		padding-top: 40upx;
	}

	.shangc-neir {
		background-color: #fff;
		padding: 40upx;
		box-sizing: border-box;
		display: flex;
		width: 100vw;
		border-bottom: 1px solid #F5F5F5;

		>input {
			flex: 1;
			text-align: center;
		}
	}

	.imgasea {
		padding-left: 25rpx;
	}

	.unpdata {
		box-sizing: border-box;
		padding: 20rpx;
		margin: 20rpx;
		text-align: center;
		background: #FF9900;
		border-radius: 20rpx;
		font-size: 40rpx;
		// color: #F5F5F5;
	}

	.picker {
		display: flex;
	}

	.juzhong {
		width: 500rpx;
		text-align: center;
	}

	.shangc-neir {
		display: flex;
		align-items: center;
		/* 垂直居中 */
		justify-content: flex-start;
		/* 横向排列 */
	}

	input {
		height: 100rpx;
	}

	label {
		margin-right: 10px;
		font-size: 16px;
	}



	.circle-btn {
		width: 40px;
		height: 40px;
		display: flex;
		justify-content: center;
		align-items: center;
		background-color: #ff6600;
		color: white;
		font-size: 24px;
		border-radius: 50%;
		/* 圆形 */
		cursor: pointer;
		margin-left: 10px;
		transition: background-color 0.3s ease;
	}

	.circle-btn:hover {
		background-color: #e65c00;
		/* 鼠标悬停时的背景颜色 */
	}
</style>s